package model.pojo;

import java.sql.ResultSet;

import models.util.MySqlDataAccessHelper;

public class AcAccountMenuLevel {
	private String iDMenuLevel;
	private String iDMenu;
	private String menuLevelName="";
	private String description;
	private String menuLevelLink;

	private AcAccountMenu menuInfo;
	
	public String getMenuLevelLink() {
		return menuLevelLink;
	}
	public void setMenuLevelLink(String menuLevelLinka) {
		menuLevelLink = menuLevelLinka;
	}
	public String getIDMenuLevel() {
		return iDMenuLevel;
	}
	public void setIDMenuLevel(String iDMenuLevela) {
		iDMenuLevel = iDMenuLevela;
	}
	public String getIDMenu() {
		return iDMenu;
	}
	public void setIDMenu(String iDMenua) {
		iDMenu = iDMenua;
	}
	public String getMenuLevelName(String lang) {
		//MenuLevelName="utilInitLang.get"+this.IDMenuLevel.replace(this.IDMenuLevel,this.IDMenuLevel.substring(0, 1).toUpperCase().concat(this.IDMenuLevel.substring(1)))+"()";
		MySqlDataAccessHelper mysql = new MySqlDataAccessHelper();
		try {
			mysql.open();
			String sql="select "+lang+" as MenuLevelName " +
					"from admin.ac_accountmenulevel, admin.configlang " +
					"where admin.ac_accountmenulevel.IDMenuLevel=admin.configlang.ID " +
					"and admin.ac_accountmenulevel.IDMenuLevel='"+this.iDMenuLevel+"'";
			ResultSet rs = mysql.executeQuery(sql);
			//System.out.println("name: "+sql);
			if(rs.next()){
				menuLevelName=rs.getString("MenuLevelName");
			}
			rs.close();
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			mysql.close();
		}
		
		return menuLevelName;
	}
	public void setMenuLevelName(String menuLevelNamea) {
		menuLevelName = menuLevelNamea;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String descriptiona) {
		description = descriptiona;
	}
	public AcAccountMenu getMenuInfo() {
		MySqlDataAccessHelper mysql = new MySqlDataAccessHelper();
		try {
			mysql.open();
			String sql="select * from admin.ac_accountmenu";
			ResultSet rs = mysql.executeQuery(sql);
			while(rs.next()){
				menuInfo.setIDMenu(rs.getString("IDMenu"));
				menuInfo.setDescription(rs.getString("Description"));
				menuInfo.setMenuLink(rs.getString("MenuLink"));
			}
			rs.close();
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			mysql.close();
		}
		return menuInfo;
	}
	public void setMenuInfo(AcAccountMenu menuInfo) {
		this.menuInfo = menuInfo;
	}
	
	
}
